package org.umss.fixturebuilder.model.appengine;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
import com.googlecode.objectify.annotation.Parent;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Daniela Menese
 */
@XmlRootElement
@Entity
public class TeamPosition {

    @Id
    private Long id;
    @Parent
    private Key<ChampionshipModel> championship;
    @Index
    private String teamName;
    @Index
    private int points;
    private int playedGames;
    private int lostGames;
    private int winGames;
    private int drawGames;

    public TeamPosition() {
    }

    public TeamPosition(Key<ChampionshipModel> championship, String teamName) {
        this.championship = championship;
        this.teamName = teamName;
    }

    public TeamPosition(String teamName, int points, int playedGames, int lostGames, int winGames, int drawGames) {
        this.teamName = teamName;
        this.points = points;
        this.playedGames = playedGames;
        this.lostGames = lostGames;
        this.winGames = winGames;
        this.drawGames = drawGames;
    }

    public String getTeamName() {
        return teamName;
    }

    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }

    public int getPoints() {
        return points;
    }

    public void setPoints(int points) {
        this.points = points;
    }

    public int getPlayedGames() {
        return playedGames;
    }

    public void setPlayedGames(int playedGames) {
        this.playedGames = playedGames;
    }

    public int getLostGames() {
        return lostGames;
    }

    public void setLostGames(int lostGames) {
        this.lostGames = lostGames;
    }

    public int getWinGames() {
        return winGames;
    }

    public void setWinGames(int winGames) {
        this.winGames = winGames;
    }

    public int getDrawGames() {
        return drawGames;
    }

    public void setDrawGames(int drawGames) {
        this.drawGames = drawGames;
    }

    public void setResult(ResultType resultType) {
        playedGames++;
        switch (resultType) {
            case DRAW:
                drawGames++;
                points++;
                break;
            case LOST:
                lostGames++;
                break;
            case WIN:
                winGames++;
                points += 3;
        }
    }
}
